// 医生页面逻辑
Page({
  data: {
    doctors: [
      {
        id: 1,
        name: "张美丽",
        title: "首席美容医师",
        specialty: "皮肤管理、抗衰老",
        experience: 8,
        rating: 4.9,
        avatar: "/images/doctor1.jpg"
      },
      {
        id: 2,
        name: "李医生",
        title: "资深美容顾问",
        specialty: "痘痘治疗、敏感肌修复",
        experience: 6,
        rating: 4.8,
        avatar: "/images/doctor2.jpg"
      },
      {
        id: 3,
        name: "王专家",
        title: "美容外科主任",
        specialty: "微整形、面部提升",
        experience: 12,
        rating: 4.95,
        avatar: "/images/doctor3.jpg"
      },
      {
        id: 4,
        name: "陈教授",
        title: "皮肤科专家",
        specialty: "色素治疗、美白淡斑",
        experience: 15,
        rating: 4.9,
        avatar: "/images/doctor4.jpg"
      }
    ],
    specialties: ["全部", "皮肤管理", "抗衰老", "痘痘治疗", "敏感肌修复", "微整形", "美白淡斑"],
    currentFilter: "全部"
  },

  onLoad() {
    console.log('医生页面加载')
  },

  // 在线咨询
  onConsult(e) {
    const doctorId = e.currentTarget.dataset.id
    const doctor = this.data.doctors.find(d => d.id === doctorId)
    
    wx.showModal({
      title: '在线咨询',
      content: `是否要咨询${doctor.name}医生？`,
      success: (res) => {
        if (res.confirm) {
          wx.showToast({
            title: '咨询请求已发送',
            icon: 'success'
          })
        }
      }
    })
  },

  // 预约医生
  onAppoint(e) {
    const doctorId = e.currentTarget.dataset.id
    const doctor = this.data.doctors.find(d => d.id === doctorId)
    
    wx.navigateTo({
      url: `/pages/appointment/appointment?doctorId=${doctorId}&doctorName=${doctor.name}`
    })
  },

  // 筛选医生
  onFilter(e) {
    const specialty = e.currentTarget.dataset.specialty
    this.setData({
      currentFilter: specialty
    })
    
    // 这里可以添加筛选逻辑
    if (specialty === "全部") {
      // 显示所有医生
    } else {
      // 按专业筛选
    }
  }
})